﻿using System;
using System.Diagnostics.CodeAnalysis;

namespace EnterpriseLibraryExtensions.Events
{
    /// <summary>
    /// The IEventRegistration interface defines how to register event handlers with the eventing system.
    /// </summary>
    public interface IEventRegistration
    {
        /// <summary>
        /// Register an event handler.
        /// </summary>
        /// <typeparam name="TEventType">The type of event the event handler handles.</typeparam>
        /// <typeparam name="TEventHandler">The type of the event handler iteself.</typeparam>
        [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Need this kind of signature to streamline with Unity.")]
        void Register<TEventType, TEventHandler>() where TEventHandler : IHandlesEvent<TEventType>;

        /// <summary>
        /// Register an inline event handler.
        /// </summary>
        /// <typeparam name="TEventType">The type of event the event handler handles.</typeparam>
        /// <param name="action">The delegate to invoke on the event being raised.</param>
        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is the desired design.")]
        void Register<TEventType>(Action<object, EventArgs<TEventType>> action);
    }
}
